<template>
  <el-form-item :label="label">
    <InputText
      v-model="value"
      :placeholder="'请输入' + label"
      @keyup.enter="searchHandler"
    />
  </el-form-item>
</template>
<script>
export default {
  name: 'SearchInput',
  emits: ['update:modelValue'],
  props: {
    modelValue: {
      required: true,
    },
    label: {
      type: String,
      required: true,
    },
    search: {
      type: Function,
      required: false,
    },
  },
  computed: {
    value: {
      get() {
        return this.modelValue
      },
      set(value) {
        this.$emit('update:modelValue', value)
      },
    },
  },
  methods: {
    searchHandler() {
      if (this.search) this.search(1)
    },
  },
}
</script>
